package es.us.isa.jdbl.domain.biblio;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import javax.persistence.Table;

@Entity
@SecondaryTables({
	@SecondaryTable(name="node", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_type_biblio", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
	@SecondaryTable(name="content_field_url", catalog = "webisa", pkJoinColumns={
			@PrimaryKeyJoinColumn(name="nid", referencedColumnName="nid")}),
})
@Table(name="biblio", catalog = "webisa")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="biblio_type", discriminatorType=DiscriminatorType.INTEGER)
public class Biblio{
	@Id
	@Column(name="nid")
	private int id;
	@Column(table="node")
	private String title;
	@Column(name="biblio_year")
	private int yearOfPublication;
	@Column(name="biblio_isbn")
	private String isbn;
	@Column(name="field_url_url", table="content_field_url")
	private String url;
	@Column(name="biblio_doi")
	private String doi;
	@Column(name="field_level_value", table="content_type_biblio")
	private String level;
	@Column(name="field_externalcollaboration_value", table="content_type_biblio")
	private boolean externalCollaboration;
	
	
	@ManyToMany
	@JoinTable(name="biblio_contributor", catalog = "webisa",
			joinColumns=@JoinColumn(name="nid"),
			inverseJoinColumns=@JoinColumn(name="cid"))
	private List<Contributors> authors;

	public Biblio(){
		
	}
	
	public void setYearOfPublication(int yearOfPublication) {
		this.yearOfPublication = yearOfPublication;
	}

	public int getYearOfPublication() {
		return yearOfPublication;
	}

	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUrl() {
		return url;
	}

	public void setDoi(String doi) {
		this.doi = doi;
	}

	public String getDoi() {
		return doi;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getLevel() {
		return level;
	}

	public void setExternalCollaboration(boolean externalCollaboration) {
		this.externalCollaboration = externalCollaboration;
	}

	public boolean getExternalCollaboration() {
		return externalCollaboration;
	}

	public void setAuthors(List<Contributors> authors) {
		this.authors = authors;
	}

	public List<Contributors> getAuthors() {
		return authors;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	
}
